package com.oet.persistence.entity;

// Generated Feb 6, 2010 2:13:01 PM by Hibernate Tools 3.2.4.GA

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * Key generated by hbm2java
 */
@Entity
@Embeddable
@Table(name = "key", catalog = "oet")
public class Key implements java.io.Serializable {

	private Long id;
	private String publicKey;
	private String privateKey;
	private String ydkBookId;
	private Date validFrom;
	private Boolean expired;

	public Key() {
	}

	public Key(String publicKey, String privateKey, Date validFrom,
			Boolean expired, String ydkBookId) {
		this.publicKey = publicKey;
		this.privateKey = privateKey;
		this.validFrom = validFrom;
		this.expired = expired;
		this.ydkBookId = ydkBookId;
	}

	public Key(Long id) {
		// TODO Auto-generated constructor stub
		this.id = id;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id")
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "public_key")
	public String getPublicKey() {
		return this.publicKey;
	}

	public void setPublicKey(String publicKey) {
		this.publicKey = publicKey;
	}

	@Column(name = "private_key")
	public String getPrivateKey() {
		return this.privateKey;
	}

	public void setPrivateKey(String privateKey) {
		this.privateKey = privateKey;
	}

	@Column(name = "valid_from")
	public Date getValidFrom() {
		return this.validFrom;
	}

	public void setValidFrom(Date validFrom) {
		this.validFrom = validFrom;
	}

	@Column(name = "expired")
	public Boolean getExpired() {
		return this.expired;
	}

	public void setExpired(Boolean expired) {
		this.expired = expired;
	}
	
	
	/**
	 * @return the ydkBookId
	 */
	@Column(name = "ydkBookId")
	public String getYdkBookId() {
		return ydkBookId;
	}
	public void setYdkBookId(String ydkBookId) {
		this.ydkBookId = ydkBookId;
	}

	@Transient
	public Key setToPlainObject(Key instance)
	{
		//Get self;
		instance.getPrivateKey();
		//Eager get @ManytoOne, @OnetoOne
		
//		Key result = new Key();
//		result.cloneKey(instance);
		//Null oneToMany;
		

		return instance;
	}
	
	@Transient
	public Key setToPlainObjectQuick(Key instance)
	{
		//Get self;
		//Eager get @ManytoOne, @OnetoOne
		instance.getPrivateKey();
		//Null oneToMany;
		
		return instance;
	}
	
	public void cloneKey(Key key) {
		id = key.id;
		publicKey = key.publicKey;
		privateKey = key.privateKey;
		validFrom = key.validFrom;
		expired = key.expired;
		ydkBookId = key.ydkBookId;
	}

}
